package com.risesoftware.battlebugs;

import java.util.UUID;

import android.app.Application;
import android.app.PendingIntent;
import android.content.Intent;
import android.util.Log;

public class ApplicationBattleBugs extends Application {

   public static final String MSG_CONNECT = "CONNECT";
   public static final String MSG_CONNECT_FORMAT = MSG_CONNECT + "=guid:%s";
   public static final String MSG_CONNECTED = "CONNECTED";
   public static final String MSG_CONNECTED_FORMAT = MSG_CONNECTED + "=guid:%s";
   public static final String MSG_BOMB = "BOMB";
   public static final String MSG_BOMB_FORMAT = MSG_BOMB + "=guid:%s;x=%s;y=%s";
   public static final String MSG_MISS = "MISS";
   public static final String MSG_MISS_FORMAT = MSG_MISS + "=guid:%s";
   public static final String MSG_HIT = "HIT";
   public static final String MSG_HIT_FORMAT = MSG_HIT + "=guid:%s;x=%s;y=%s";
   public static final String MSG_SUNK = "SUNK";
   public static final String MSG_SUNK_FORMAT = MSG_SUNK + "=guid:%s;x=%s;y=%s";
   public static final String MSG_YOU_WIN= "YOU_WIN";
   public static final String MSG_YOU_WIN_FORMAT= MSG_YOU_WIN + "=guid:%s";
   public static final String MSG_SLAVE = "SLAVE";
   public static final String MSG_SLAVE_FORMAT = MSG_SLAVE + "=guid:%s;id=%s";
   public static final String MSG_YES_MASTER = "YES_MASTER";
   public static final String MSG_YES_MASTER_FORMAT = MSG_YES_MASTER + "=guid:%s;id=%s";
   public static final String MSG_NEW_GAME = "NEW_GAME";
   public static final String MSG_NEW_GAME_FORMAT = MSG_NEW_GAME + "=guid:%s";
   public static final String MSG_RESET = "RESET";
   public static final String MSG_RESET_FORMAT = MSG_RESET + "=guid:%s";
   public static final String MSG_QUIT = "QUIT";
   public static final String MSG_QUIT_FORMAT = MSG_QUIT + "=guid:%s";
   public static final String MSG_ACK = "ACK";
   public static final String MSG_ACK_FORMAT = MSG_ACK + "=guid:%s";
   
   public static final UUID MY_UUID = UUID.randomUUID();
   
   /*
    * (non-Javadoc)
    * 
    * @see android.app.Application#onCreate()
    */
   @Override
   public void onCreate() {
      // TODO Auto-generated method stub
      super.onCreate();
      StartRegistrationNotification();
   }


   public void StartRegistrationNotification() {
      Log.w("C2DM", "start registration process");

      Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
      registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
      registrationIntent.putExtra("sender", "wallace.mikewallace@gmail.com");
      startService(registrationIntent);
   }
}
